:: Remote
-> ImportTreeConfig
-> ImportCommitConfig
+ -> AddUnlockedMatcher
-> Imported
-> Annex (Maybe Ref)
-buildImportCommit remote importtreeconfig importcommitconfig imported =
+buildImportCommit remote importtreeconfig importcommitconfig addunlockedmatcher imported =
case importCommitTracking importcommitconfig of
Nothing -> go Nothing
Just trackingcommit -> inRepo (Git.Ref.tree trackingcommit) >>= \case
Just _ -> go (Just trackingcommit)
where
go trackingcommit = do
- (importedtree, updatestate) <- recordImportTree remote importtreeconfig imported
+ (importedtree, updatestate) <- recordImportTree remote importtreeconfig (Just addunlockedmatcher) imported
buildImportCommit' remote importcommitconfig trackingcommit importedtree >>= \case
Just finalcommit -> do
updatestate
recordImportTree
:: Remote
-> ImportTreeConfig
+ -> Maybe AddUnlockedMatcher
-> Imported
-> Annex (History Sha, Annex ())
-recordImportTree remote importtreeconfig imported = do
- importedtree@(History finaltree _) <- buildImportTrees basetree subdir imported
+recordImportTree remote importtreeconfig addunlockedmatcher imported = do
+ importedtree@(History finaltree _) <- buildImportTrees basetree subdir addunlockedmatcher imported
return (importedtree, updatestate finaltree)
where
basetree = case importtreeconfig of
}
return oldexport
- -- downloadImport takes care of updating the location log
+ -- importKeys takes care of updating the location log
-- for the local repo when keys are downloaded, and also updates
-- the location log for the remote for keys that are present in it.
-- That leaves updating the location log for the remote for keys
buildImportTrees
:: Ref
-> Maybe TopFilePath
+ -> Maybe AddUnlockedMatcher
-> Imported
-> Annex (History Sha)
-buildImportTrees basetree msubdir (ImportedFull imported) =
- buildImportTreesGeneric convertImportTree basetree msubdir imported
-buildImportTrees basetree msubdir (ImportedDiff (LastImportedTree oldtree) imported) = do
+buildImportTrees basetree msubdir addunlockedmatcher (ImportedFull imported) =
+ buildImportTreesGeneric (convertImportTree addunlockedmatcher) basetree msubdir imported
+buildImportTrees basetree msubdir addunlockedmatcher (ImportedDiff (LastImportedTree oldtree) imported) = do
importtree <- if null (importableContents imported)
then pure oldtree
else applydiff
oldtree
mktreeitem (loc, DiffChanged v) =
- Just <$> mkImportTreeItem msubdir loc v
+ Just <$> mkImportTreeItem addunlockedmatcher msubdir loc v
mktreeitem (_, DiffRemoved) =
pure Nothing
isremoved (_, v) = v == DiffRemoved
-convertImportTree :: Maybe TopFilePath -> [(ImportLocation, Either Sha Key)] -> Annex Tree
-convertImportTree msubdir ls =
- treeItemsToTree <$> mapM (uncurry $ mkImportTreeItem msubdir) ls
+convertImportTree :: Maybe AddUnlockedMatcher -> Maybe TopFilePath -> [(ImportLocation, Either Sha Key)] -> Annex Tree
+convertImportTree maddunlockedmatcher msubdir ls =
+ treeItemsToTree <$> mapM (uncurry $ mkImportTreeItem maddunlockedmatcher msubdir) ls
-mkImportTreeItem :: Maybe TopFilePath -> ImportLocation -> Either Sha Key -> Annex TreeItem
-mkImportTreeItem msubdir loc v = case v of
- Right k -> do
- relf <- fromRepo $ fromTopFilePath topf
- symlink <- calcRepo $ gitAnnexLink relf k
- linksha <- hashSymlink symlink
- return $ TreeItem treepath (fromTreeItemType TreeSymlink) linksha
+mkImportTreeItem :: Maybe AddUnlockedMatcher -> Maybe TopFilePath -> ImportLocation -> Either Sha Key -> Annex TreeItem
+mkImportTreeItem maddunlockedmatcher msubdir loc v = case v of
+ Right k -> case maddunlockedmatcher of
+ Nothing -> mklink k
+ Just addunlockedmatcher -> do
+ objfile <- calcRepo (gitAnnexLocation k)
+ let mi = MatchingFile FileInfo
+ { contentFile = objfile
+ , matchFile = getTopFilePath topf
+ , matchKey = Just k
+ }
+ ifM (checkAddUnlockedMatcher NoLiveUpdate addunlockedmatcher mi)
+ ( mkpointer k
+ , mklink k
+ )
+
Left sha ->
return $ TreeItem treepath (fromTreeItemType TreeFile) sha
where
treepath = asTopFilePath lf
topf = asTopFilePath $
maybe lf (\sd -> getTopFilePath sd P.</> lf) msubdir
+ mklink k = do
+ relf <- fromRepo $ fromTopFilePath topf
+ symlink <- calcRepo $ gitAnnexLink relf k
+ linksha <- hashSymlink symlink
+ return $ TreeItem treepath (fromTreeItemType TreeSymlink) linksha
+ mkpointer k = TreeItem treepath (fromTreeItemType TreeFile)
+ <$> hashPointerFile k
{- Builds a history of git trees using ContentIdentifiers.
-
- generates Keys without downloading.
-
- Generates either a Key or a git Sha, depending on annex.largefiles.
- - But when importcontent is False, it cannot match on annex.largefiles
- - (or generate a git Sha), so always generates Keys.
+ - But when importcontent is False, it cannot generate a git Sha,
+ - so always generates Keys.
-
- Supports concurrency when enabled.
-
(pure Nothing)
(Just <$$> inRepo . toTopFilePath . toRawFilePath)
(importToSubDir o)
+ addunlockedmatcher <- addUnlockedMatcher
seekRemote r (importToBranch o) subdir (importContent o)
(checkGitIgnoreOption o)
+ addunlockedmatcher
(messageOption o)
startLocal :: ImportOptions -> AddUnlockedMatcher -> GetFileMatcher -> DuplicateMode -> (RawFilePath, RawFilePath) -> CommandStart
verifyEnoughCopiesToDrop [] key Nothing Nothing needcopies mincopies [] preverified tocheck
(const yes) no
-seekRemote :: Remote -> Branch -> Maybe TopFilePath -> Bool -> CheckGitIgnore -> [String] -> CommandSeek
-seekRemote remote branch msubdir importcontent ci importmessages = do
+seekRemote :: Remote -> Branch -> Maybe TopFilePath -> Bool -> CheckGitIgnore -> AddUnlockedMatcher -> [String] -> CommandSeek
+seekRemote remote branch msubdir importcontent ci addunlockedmatcher importmessages = do
importtreeconfig <- case msubdir of
Nothing -> return ImportTree
Just subdir ->
trackingcommit <- fromtrackingbranch Git.Ref.sha
cmode <- annexCommitMode <$> Annex.getGitConfig
let importcommitconfig = ImportCommitConfig trackingcommit cmode importmessages'
- let commitimport = commitRemote remote branch tb trackingcommit importtreeconfig importcommitconfig
+ let commitimport = commitRemote remote branch tb trackingcommit importtreeconfig importcommitconfig addunlockedmatcher
importabletvar <- liftIO $ newTVarIO Nothing
void $ includeCommandAction (listContents remote importtreeconfig ci importabletvar)
, err
]
-commitRemote :: Remote -> Branch -> RemoteTrackingBranch -> Maybe Sha -> ImportTreeConfig -> ImportCommitConfig -> Imported -> CommandStart
-commitRemote remote branch tb trackingcommit importtreeconfig importcommitconfig imported =
+commitRemote :: Remote -> Branch -> RemoteTrackingBranch -> Maybe Sha -> ImportTreeConfig -> ImportCommitConfig -> AddUnlockedMatcher -> Imported -> CommandStart
+commitRemote remote branch tb trackingcommit importtreeconfig importcommitconfig addunlockedmatcher imported =
starting "update" ai si $ do
- importcommit <- buildImportCommit remote importtreeconfig importcommitconfig imported
+ importcommit <- buildImportCommit remote importtreeconfig importcommitconfig addunlockedmatcher imported
next $ updateremotetrackingbranch importcommit
where
ai = ActionItemOther (Just $ UnquotedString $ fromRef $ fromRemoteTrackingBranch tb)
import Annex.Wanted
import Annex.Content
import Annex.WorkTree
+import Annex.FileMatcher
import Command.Get (getKey')
import qualified Command.Move
import qualified Command.Export
import Annex.Import
import Annex.CheckIgnore
import Annex.PidLock
-import Types.FileMatcher
import Types.GitConfig
import Types.Availability
import qualified Database.Export as Export
let (branch, subdir) = splitRemoteAnnexTrackingBranchSubdir b
if canImportKeys remote importcontent
then do
- Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True) []
+ addunlockedmatcher <- addUnlockedMatcher
+ Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True) addunlockedmatcher []
-- Importing generates a branch
-- that is not initially connected
-- to the current branch, so allow
where
go (Just importable) = importChanges remote ImportTree False True importable >>= \case
ImportFinished imported -> do
- (_t, updatestate) <- recordImportTree remote ImportTree imported
+ (_t, updatestate) <- recordImportTree remote ImportTree Nothing imported
next $ do
updatestate
return True